import React from 'react'
import {Tooltip} from '../../antd'

class TooltipText extends React.Component {
    render() {
        let {text, showLength} = this.props;
        let showTips = false;
        if (text !== undefined && showLength!=='' && showLength !== undefined && text.length > showLength) {
            text = text.substring(0, showLength) + "···";
            showTips = true;
        }
        if (showTips) {
            return (
                <div>
                    <Tooltip placement="top" title={this.props.text} arrowPointAtCenter autoAdjustOverflow>
                        <span>{text}</span>
                    </Tooltip>
                </div>
            );
        } else {
            return (
                <span>{this.props.text}</span>
            );
        }
    }
}

export default TooltipText;